<?php
include_once(dirname(__FILE__)."../../TMS_TEDxCairo_DATABASE_DAO/UserDAO.class.php");
$userDao = new UserDAO();
$userRoles = $userDao->listUserRoles();
if($_GET['action']=='view'){
    $users = $userDao->listAll();
    include_once ('views/viewUsers.html');
    exit;
}
if($_POST['action']=='save'){
    if(isset($_POST['userId'])){
        $user = $userDao->editUserDetails($_POST['email'], $_POST['password'], $_POST['firstName'], $_POST['lastName'], $_POST['mobile'], $_POST['userId'],$_POST['userRole']);
    }else{
    $user = $userDao->addUser($_POST['email'], $_POST['password'], $_POST['firstName'], $_POST['lastName'], $_POST['mobile'], $_POST['userRole']);
    }
    $users = $userDao->listAll();
    include_once ('views/header.html');
    include_once ('views/viewUsers.html');
    include_once ('views/footer.html');
    exit;
    
}elseif ($_GET['action']=='edit') {
    $user = $userDao->get($_GET['userId']);
    include_once ("views/user.html");
    exit;
}

include_once ("views/user.html");
?>
